package com.zoo.diannaopeijian.controller.entry;

import com.zoo.diannaopeijian.controller.BaseController;
import com.zoo.diannaopeijian.domain.SupplyChannel;
import com.zoo.diannaopeijian.service.SupplyChannelService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by zx583 on 2018-01-21.
 */
@Controller
@RequestMapping("/SupplyChannel")
public class SupplyChannelController extends BaseController {
    @Resource
    private SupplyChannelService supplyChannelService;

    @RequestMapping("SupplyChannelManaPage")
    public String SupplyChannelManaPageRoute() {
        return "entry/supplychannel/SupplyChannelManaPage";
    }

    @RequestMapping("SupplyChannelAddPage")
    public String SupplyChannelAddPageRoute() {
        return "entry/supplychannel/SupplyChannelAddPage";
    }

    @RequestMapping("SupplyChannelUpdatePage")
    public String SupplyChannelUpdatePage() {
        return "entry/supplychannel/SupplyChannelUpdatePage";
    }

    @RequestMapping("/getAllSupplyChannel")
    @ResponseBody
    public List<SupplyChannel> getAllSupplyChannel() {
        return supplyChannelService.getAllSupplyChannel();
    }

    @RequestMapping("/addSupplyChannel")
    @ResponseBody
    public String addSupplyChannel(SupplyChannel supplyChannel) {
        return supplyChannelService.addSupplyChannel(supplyChannel) ? success : fail;
    }

    @RequestMapping("/updateSupplyChannel")
    @ResponseBody
    public String updateSupplyChannel(SupplyChannel supplyChannel) {
        return supplyChannelService.updateSupplyChannel(supplyChannel) ? success : fail;
    }

    @RequestMapping("/deleteSupplyChannel")
    @ResponseBody
    public String deleteSupplyChannel(Integer supplychannelid) {
        return supplyChannelService.deleteSupplyChannel(supplychannelid) ? success : fail;
    }
}
